<p> Positioning </p> <!--You can try the next code yourself.--> <div style='width:400px; height:200px; border:5px solid Black;'> <div style='width:200px; height:200px; border:5px solid Blue;'></div> <div style='width:200px; height:200px; border:5px solid Green;'> <p style='width:100px; text-align:center; border:5px solid Purple;'> Hmmmmm </p> <p style='width:100px; text-align:center; border:5px solid Red;'> Interesting! </p> </div> </div>
<p> Positioning </p> <!--You can try the next code yourself.--> <div style='position:relative; top:-50px; left:50px; width:400px; height:200px; border:5px solid Black;'> <div style='position:absolute; top:50px; right: -50px; width:200px; height:200px; border:5px solid Blue;'></div> <div style='position:relative; top:100px; right: -100px; width:200px; height:200px; border:5px solid Green;'> <p style='position:absolute; top:100px; left:100px; margin:0px; width:100px; text-align:center; border:5px solid Purple;'> Hmmmmm </p> <p style='position:relative; left:50px; top:50px; margin:0px; width:100px; text-align:center; border:5px solid Red;'> Interesting! </p> </div> </div>
Positioning
Hmmmmm
Interesting!
(Press the button and hold it to see :active!)
<style> p { background-color: LightYellow; } p.tr6-left { width: 70%; ???-right: auto; } p.tr6-right { width: 70%; ???-left: ???; } p.tr6-hcenter { width: 50%; ???: ???; } p.tr6-just { margin-top: 100px; margin-bottom: 50px; margin-left: 100px; margin-right: 50px; } p.tr6-inside { width: 60%; ???: ???; } </style> <p>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p> <p class='tr6-left'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p> <p class='tr6-right'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p> <p class='tr6-hcenter'>Horizontal centering</p> <p class='tr6-just'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p> <div style='width:50%; height:100px; border: 1px solid black;'> <p class='tr6-inside'>Horizontal centering</p> </div>Can you imagine how the above paragraphs will be displayed?
<p style='???:???; bottom:20px; left:calc(???); background-color:LightGrey; width:150px; text-align:center; z-index:1; font-size:200%'> <a ???='//cs.tru.ca'>cs.tru.ca </p>
<style> div.tr9-outside { ???:???; ???:???; width:400px; height:300px; border:1px solid blue; } </style> <p>Vertical centering. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p> <div class='tr9-outside'> <p style='text-align:center; width:60%; ???:???; background-color:LightGreen;'> (Note that the height is not specified, which means not easy to use calc().) This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p> </div>